package com.yadang.infra.service;

import com.yadang.infra.bean.CmmDictDetail;
import com.yadang.infra.bean.CmmDictType;
import com.yadang.infra.mapper.CmmDictDetailMapper;
import com.yadang.infra.tools.SnowFlakeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CmmDictDetailService {
    @Autowired
    private CmmDictDetailMapper cmmDictDetailMapper;

    public int insert(CmmDictType dictType, String key, String value, String detailDesc) {

        CmmDictDetail cmmDictDetail = new CmmDictDetail();
        cmmDictDetail.setId(SnowFlakeUtil.getId());
        cmmDictDetail.setDictTypeId(dictType.getId());
        cmmDictDetail.setKey(key);
        cmmDictDetail.setValue(value);
        cmmDictDetail.setDescription(detailDesc);
        cmmDictDetail.setCreateDate(new Date());
        cmmDictDetail.setUpdateDate(new Date());
        return cmmDictDetailMapper.insert(cmmDictDetail);
    }
}
